package com.qyer.search.db;

import com.qyer.commons.persistence.AbstractDBResourceManager;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Created by tangzheng on 16/3/7.
 */
public class MainDBResourceManager extends AbstractDBResourceManager {
  private static final Logger LOGGER = LoggerFactory.getLogger(MainDBResourceManager.class);
  private static class InnerHolder {
    private static final MainDBResourceManager INSTANCE = new MainDBResourceManager();
  }

  public static final MainDBResourceManager getInstance() {
    return InnerHolder.INSTANCE;
  }

  private MainDBResourceManager() {
    CompositeConfiguration c = new CompositeConfiguration();
    c.addConfiguration(new SystemConfiguration());
    String file = c.getString("search.db.main.properties.location", "/etc/search/db.main.properties");
    try {
      initByLocalConf(file);
    } catch (Exception e) {
      LOGGER.error("Cannot load local config file(" + file + ").", e);
    }
  }
}
